package com.imnc.eatmap.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.PoiOverlay;
import com.baidu.mapapi.map.PopupClickListener;
import com.baidu.mapapi.map.PopupOverlay;
import com.baidu.mapapi.search.MKPoiInfo;
import com.baidu.mapapi.search.MKSearch;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.imnc.eatmap.R;
import com.imnc.eatmap.model.PoiInfoParcelable;
import com.imnc.eatmap.ui.MainActivity;
import com.imnc.eatmap.ui.PoiResultDetailActivity;

public class EatMapPoiOverlay extends PoiOverlay {

	private MKSearch mSearch;
	private Activity mContext;
	private PopupOverlay pop = null;
	private PopupClickListener popListener = null;

	public EatMapPoiOverlay(Activity activity, MapView mapView, MKSearch search) {
		super(activity, mapView);
		mContext = activity;
		mSearch = search;

		popListener = new PopupClickListener() {

			@Override
			public void onClickedPopup(int arg0) {

			}
		};

		pop = new PopupOverlay(mapView, popListener);
	}

	@Override
	protected boolean onTap(int i) {
		super.onTap(i);
		MKPoiInfo info = getPoi(i);

		// View view = LayoutInflater.from(mContext).inflate(R.layout.pop,
		// null);

		// pop.showPopup(view, info.pt, 32);

		// if (info.hasCaterDetails) {
		// mSearch.poiDetailSearch(info.uid);
		// } else {
		Intent intent = new Intent(mContext, PoiResultDetailActivity.class);

		PoiInfoParcelable poiInfoParcelable = new PoiInfoParcelable(info);
		Bundle bundle = new Bundle();
		bundle.putParcelable("poiInfoParcelable", poiInfoParcelable);
		intent.putExtras(bundle);
		mContext.startActivityForResult(intent,
				MainActivity.REQUEST_ROUTE_PLANNING);
		// }
		return false;
	}

}
